import { Entity, Column } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { ArrayToStringTransformer } from 'src/utils/ArrayToString';
import { Base } from 'src/entities/Base';

@Entity('sys_user')
export class User extends Base {
    @Column({ nullable: false, comment: '账号状态', default: 0 })
    @ApiProperty()
    status: number;

    @Column({ nullable: false, comment: '唯一ID', })
    @ApiProperty()
    guid: string;

    @Column({ nullable: true, comment: '手机号' })
    @ApiProperty()
    mobile: string;

    @Column({ nullable: false, comment: '密码' })
    @ApiProperty()
    password: string;

    @Column({ nullable: false, comment: '盐' })
    @ApiProperty()
    salt: string;

    @Column({ nullable: true, comment: '头像' })
    @ApiProperty()
    avatar: string;

    @Column({ nullable: true, comment: '头像' })
    @ApiProperty()
    hash: string;

    @Column({ name: 'user_name', nullable: false, comment: '真实姓名' })
    @ApiProperty()
    userName: string;

    @Column({ transformer: new ArrayToStringTransformer(), default: 'visitor', comment: '角色' })
    @ApiProperty()
    role: string;
}
